<template>
	<view>
		<u-collapse ref='coll' :value="['1','2']">
			<u-collapse-item name="1" title="维护信息" icon="order">
				<u-cell-group>
					<u-cell title="所在部门" :use-label-slot="true">
						<span slot="label" class="cell-label">{{ordertail.OrderDept || " "}}</span>
					</u-cell>
					<u-cell title="工单编号" :use-label-slot="true">
						<span slot="label" class="cell-label">{{ordertail.No || " "}}</span>
					</u-cell>
					<u-cell title="网络类型" :use-label-slot="true">
						<span slot="label" class="cell-label">{{ordertail.NetType || " "}}</span>
					</u-cell>
					<u-cell title="接单日期" :use-label-slot="true">
						<span slot="label" class="cell-label">{{ordertail.AcceptanceTime || " "}}</span>
					</u-cell>
					<u-cell title="完工时间" :use-label-slot="true">
						<span slot="label" class="cell-label">{{ordertail.FinishTime || " "}}</span>
					</u-cell>
					<u-cell title="部门" :use-label-slot="true">
						<span slot="label" class="cell-label">{{ordertail.Dept || " "}}</span>
					</u-cell>
					<u-cell title="辖区" :use-label-slot="true">
						<span slot="label" class="cell-label">{{ordertail.District || " "}}</span>
					</u-cell>
					<u-cell title="工单来源" :use-label-slot="true">
						<span slot="label" class="cell-label">{{ordertail.Source || " "}}</span>
					</u-cell>

					<!-- <u-cell title="经度" :use-label-slot="true">
						<span slot="label" class="cell-label">{{ordertail.Lat || " "}}</span>
					</u-cell>
					<u-cell title="纬度" :use-label-slot="true">
						<span slot="label" class="cell-label">{{ordertail.Lng || " "}}</span>
					</u-cell> -->
					<u-cell title="故障地址" :use-label-slot="true">
						<span slot="label" class="cell-label">{{ordertail.Address || " "}}</span>
					</u-cell>
					<u-cell title="故障描述" :use-label-slot="true">
						<span slot="label" class="cell-label">{{ordertail.Content || " "}}</span>
					</u-cell>
					<u-cell title="维护类型" :use-label-slot="true">
						<span slot="label" class="cell-label">{{ordertail.FaultType || " "}}</span>
					</u-cell>
					<u-cell title="派单部门" :use-label-slot="true">
						<span slot="label" class="cell-label">{{ordertail.SendOrderDept || " "}}</span>
					</u-cell>
					<u-cell title="派单人" :use-label-slot="true">
						<span slot="label" class="cell-label">{{ordertail.SendOrderManName || " "}}</span>
					</u-cell>
					<u-cell title="润象接单人" :use-label-slot="true">
						<span slot="label" class="cell-label">{{ordertail.ReceiveOrderManName || " "}}</span>
					</u-cell>
					<u-cell title="标准地址" :use-label-slot="true">
						<span slot="label" class="cell-label">{{ordertail.StandardAddress || " "}}</span>
					</u-cell>
					<u-cell title="提交人" :use-label-slot="true">
						<span slot="label" class="cell-label">{{ordertail.Creator.Name || " "}}</span>
					</u-cell> 
				</u-cell-group>
			</u-collapse-item>
			<u-collapse-item name="2" title="照片" icon="https://project.gxrunxiang.com/cdn/image.png">
				<u-album :urls="imagesurls1"></u-album>
			</u-collapse-item>
		<u-button type="error" :plain="true" v-if="user.Id == ordertail.CreatorId"
			@click="delmodalShow = true">删除</u-button>
		</u-collapse>
		<u-toast ref="uToast"></u-toast>
		<u-modal :show="delmodalShow" title="提示" content='确认删除?' @confirm="del" :showCancelButton="true"
			confirmText="是" cancelText="否" @cancel="delmodalShow = false" :closeOnClickOverlay="true"
			@close="delmodalShow = false"></u-modal>
	</view>
</template>
<script>
	import {
		baseUrl
	} from '@/common/config.js'
	import {
		mapGetters
	} from 'vuex'
	import {
		getorderlist,
		getfilebyoutid,
		delorder
		// pingfault,
		// checkZTEpoint,
		// CheckToppoint
	} from '@/common/api.js'
	export default {
		data() {
			return {
				orderId: "",
				ordertail: {
					Creator:{
						Name: ""
					}
				},
				imagesurls1: [],
				modalShow: false,
				delmodalShow: false,
				user: {}
			}
		},
		onLoad(option) {
			this.user = JSON.parse(uni.getStorageSync("$userinfo"))
			this.orderId = option.Id
			this.getlist(this.orderId)
		},
		methods: {
			async getlist(id) {
				let para = {
					Parameters: [],
				}
				para.Parameters.push({
					FieldName: "Id",
					ConditionalType: "Equal",
					FieldValue: id
				})
				await getorderlist(para).then(res => {
					this.ordertail = res.data[0]
				})
				this.imagesurls1 = []
				getfilebyoutid(this.orderId).then(res => {
					for (var i = 0; i < res.length; i++) {
						this.imagesurls1.push(`${baseUrl}/SysFile/download?id=${res[i].Id}`)
					}
					setTimeout(() => {
							this.$refs.coll.init()
						},
						1000)
				})
				console.log(this.imagesurls1)
			},
			del(){
				let ids = []
				ids.push(this.orderId)
				delorder(ids).then((res) => {
					if (res == true)
						uni.navigateBack()
				})
				},
		}
	}
</script>
<style>
	.cell-label {
		margin-top: 10px;
		font-size: 14px;
		color: #909193;
	}
</style>